<!doctype html>
<script>
function test()
{
    if (window.location.hash === "#test") {
        if (window.testRunner)
            testRunner.notifyDone();
        return;
    }

    window.onpopstate = () => {
        document.getElementById('link').textContent = 'FAIL, same document';
        if (window.testRunner)
            testRunner.notifyDone();
    };

    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();

        var a = document.querySelector("#link");
        eventSender.mouseMoveTo(a.offsetLeft + 10, a.offsetTop + 10);
        eventSender.mouseDown(1, []);
        eventSender.mouseUp(1, []);
    }
}
</script>
<body onload="test()">
<p>Tests that middle button click on a fragment link results in a new tab.</p>
<a href="#test" id="link">SUCCESS, no same-document navigation</a>
</body>
